<?php
class recommend_relationModel extends baseModel{
    protected $table = 'recommend_relation';

    //保存推荐位关联
    public function content_save($str=null,$aid) {
        if(empty($str)){
            return false;
        }
        $this->content_del($aid);
        $str=explode(',', $str);
        foreach ($str as $value) {
            $data['pid']=$value;
            $data['aid']=$aid;
            $this->insert($data);
        }
    }

    //通过推荐位内容关联
    public function relation_del($pid) {
        return $this->delete('pid='.$pid);
    }

    //删除内容推荐关联
    public function content_del($aid) {
        return $this->delete('aid='.$aid);
    }

    //获取推荐位数组
    public function relation_array($aid){
        $list=$this->select('aid='.$aid);
        if(empty($list)){
            return false;
        }
        foreach ($list as $value) {
            $recommend[]=$value['pid'];
        }
        return $recommend;
    }
	
}